package com.example.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class Thymeleafcontroller {

    @GetMapping("/")
    public String example(Model model) {
        model.addAttribute("message", "Thymeleaf case");
        model.addAttribute("items", new String[]{"case 1", "case 2", "case 3"});
        model.addAttribute("user", new User("ABC"));
        model.addAttribute("loggedIn", true);
        return "index";
    }

    @Controller
    public class HomeController {

        @GetMapping("/hello")
        public String home(Model model) {
            model.addAttribute("name", "World");
            return "home";
        }
    }

    public static class User {
        private String name;

        public User(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
